package com.zllkj.mm.module.home.fragments

import com.bumptech.glide.provider.LoadProvider
import com.zllkj.mm.R
import com.zllkj.mm.api.network.RetrofitHelper
import com.zllkj.mm.api.network.RxHelper
import com.zllkj.mm.api.network.subscriber.ProgressSubscriber
import com.zllkj.mm.base.BaseTitleFragment
import com.zllkj.mm.model.entity.NearByGoodsListBean
import com.zllkj.mm.model.entity.UserDetailVo
import com.zllkj.mm.module.goods.vm.ItemNearByShopGoodsVM
import com.zllkj.mm.util.common.FormatUtil
import com.zllkj.mm.util.common.PictureLoadUtil
import kotlinx.android.synthetic.main.fragment_friend_detail.view.*
import kotlinx.android.synthetic.main.fragment_user_detail.view.*
import kotlinx.android.synthetic.main.fragment_user_detail.view.ivhead
import java.util.HashMap

class UserDetailFragment(val userId:Int):BaseTitleFragment() {
    override fun getContentLayoutId(): Int {
        return R.layout.fragment_user_detail
    }

    override fun loadData() {
        super.loadData()

        addSubscribe(RetrofitHelper.getInstance().api.getUserDetailById((HashMap<String, Any>().apply {
            this["id"] = userId

        })).compose<UserDetailVo>(RxHelper.defaultHandleResult<UserDetailVo>()).subscribe(object : ProgressSubscriber<UserDetailVo>(requireContext()) {
            override fun onSucc(t: UserDetailVo?) {
                t?.let {
                    PictureLoadUtil.loadPic(mRootView.ivhead,t?.userLogo)
                    var address = "|" + it.province + it.city
                    mRootView.tv_age_and_sex.text = if(it.sex == 1)"男" else "女"
                    mRootView.tv_age_and_sex.append(address)
                }
            }

            override fun onError(e: Throwable?) {
                super.onError(e)
            }
        }))

    }


}